package com.xk.school_device.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xk.school_device.common.Result;
import com.xk.school_device.entity.Devices;
import com.xk.school_device.entity.rep.ReturnDeviceReq;
import com.xk.school_device.mapper.DevicesMapper;
import com.xk.school_device.service.IAssignmentsService;
import com.xk.school_device.service.IDevicesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xk
 * @since 2025-04-16
 */
@Service
public class DevicesServiceImpl extends ServiceImpl<DevicesMapper, Devices> implements IDevicesService {

    @Autowired
    private DevicesMapper devicesMapper;



    @Override
    public void updateDevices(Devices devices) {
        devicesMapper.updateDevices(devices);
    }

    @Override
    public void deleteDevice(Devices devices) {
        devicesMapper.delete(new QueryWrapper<>(devices));
    }

    @Override
    public void updateMaintenanceId(String deviceId, String underMaintenance) {
        devicesMapper.updateMaintenanceId(deviceId,underMaintenance);
    }

    @Override
    public Devices getByIdDevice(String deviceId) {
        return devicesMapper.getDeviceById(deviceId);
    }

    @Override
    public void updateByIdDisposed(Devices device) {
         devicesMapper.updateByIdStatus(device.getDeviceId(),"disposed");
    }

    @Autowired
    private IAssignmentsService assignmentsService;

}
